package org.zjvis.datascience.common.enums;

import org.zjvis.datascience.common.exception.DataScienceException;

/**
 * @description Python算子节点类型 枚举类
 * @date 2021-12-16
 */
public enum AlgPyEnum {
    ANOMALY_STAT("异常值检测-统计", 1, "anomaly_stat"),
    ANOMALY_KNN("异常值检测-近邻", 2, "anomaly_knn"),
    IMPUTATION_STAT("缺失值插补-通用", 3, "imputation_stat"),
    IMPUTATION_MULTI("缺失值插补-多重", 4, "imputation_multi"),
    FEATURE_SCALING("标准化", 5, "standardization"),
    TIMESERIES_DECOMPOSE("时间序列分解", 6, "timeseries_decompose"),
    FEATURE_SMOOTHING("数据平滑", 7, "smoothing"),
    DBSCAN("聚类-DBSCAN", 13, "dbscan"),
    KMEANS("聚类-KMEANS", 14, "kmeans"),
    PCA("降维-PCA", 15, "pca"),
    TSNE("降维-TSNE", 16, "tsne"),

    // 新版迁移算法
    KMEANS_NEW("(新)聚类-KMEANS", 17, "new_kmeans"),
    DBSCAN_NEW("(新)聚类-DBSCAN", 18, "new_dbscan"),
    PCA_NEW("(新)降维-PCA", 19, "new_pca"),
    TSNE_NEW("(新)降维-TSNE", 20, "new_tsne"),
    LLE_NEW("(新)LLE", 21, "new_lle"),
    ISO_FOREST_NEW("(新)孤立森林异常值检测", 22, "new_iso_forest"),
    FP_GROWTH_NEW("(新)FP-Growth", 23, "new_fp_growth"),
    PREFIX_SPAN_NEW("(新)PrefixSpan", 24, "new_prefix_span"),
    ARIMA_NEW("(新)ARIMA", 25, "new_arima"),
    HOLT_WINTERS_NEW("(新)Holt-Winters", 26, "new_holt_winters"),
    SHIFT_NEW("(新)时间序列移位", 27, "new_shift"),
    ADF_NEW("(新)ADF平稳性检验", 28, "new_adf"),


    ;

    private String desc;

    private int val;

    private String name;

    AlgPyEnum(String desc, int val, String name) {
        this.desc = desc;
        this.val = val;
        this.name = name;
    }

    public boolean isNeedAlgo() {
        return this.equals(KMEANS_NEW) || this.equals(DBSCAN_NEW)
                || this.equals(PCA_NEW) || this.equals(TSNE_NEW)
                || this.equals(LLE_NEW) || this.equals(ISO_FOREST_NEW)
                || this.equals(FP_GROWTH_NEW) || this.equals(PREFIX_SPAN_NEW)
                || this.equals(ARIMA_NEW) || this.equals(HOLT_WINTERS_NEW)
                || this.equals(SHIFT_NEW) || this.equals(ADF_NEW);
//        return false;
    }

    public String getDesc() {
        return desc;
    }

    public int getVal() {
        return val;
    }

    public String getName() {
        return name;
    }

    public static AlgPyEnum getEnumByDesc(String desc) {
        for (AlgPyEnum alg : AlgPyEnum.values()) {
            if (alg.desc.equals(desc)) {
                return alg;
            }
        }
        throw new DataScienceException("AlgPyEnum does not exist!");
    }

    public static AlgPyEnum getEnumByVal(int val) {
        for (AlgPyEnum alg : AlgPyEnum.values()) {
            if (alg.val == val) {
                return alg;
            }
        }
        throw new DataScienceException("AlgPyEnum does not exist!");
    }

    public static AlgPyEnum getEnumByName(String name) {
        for (AlgPyEnum alg : AlgPyEnum.values()) {
            if (alg.name.equals(name)) {
                return alg;
            }
        }
        throw new DataScienceException("AlgPyEnum does not exist!");
    }
}
